import random
output_byte = 0
tabletogenerate = int(input("Please enter the DECIMAL number of bytes you want to corrupt."))
if(tabletogenerate <= 0):
        print "Error. Input less than 1."
        print "Terminating program."
else:
        

        fout = open("bytes.bin", "w+")

        loopnumber = tabletogenerate
        print "Generating bytes..."
        while(tabletogenerate >= 0):
                

                output_byte = hex(random.randint(0,255))


                fout.write(output_byte)
                tabletogenerate = tabletogenerate - 1
        print "Closing file..."
        fout.close()
        output_byte = 0
        print "Running integrity check..."
        if(output_byte == 0):
                print "Terminating..."
                print "Done!"
        else:
                print "Failed integrity check. Termination failed. Retrying..."
                while (1 == 1):
                        print "Retrying..."
                        print "Failed."




